<!DOCTYPE html>
<html>
    <head>
        <#include "head-file.htm">
        <link rel="stylesheet" type="text/css" href="{ms:global.host/}/{ms:global.style/}/css/jquery.sinaemotion.css" />
        <script type="text/javascript" src="{ms:global.host/}/{ms:global.style/}/js/jquery.sinaEmotion.js"></script>
    </head>

    <body>
        <#include "head.htm">
        <div class="ms-banner" style="background:url({ms:global.host/}/{ms:global.style/}images/news2.png) no-repeat center;">
            <p class="banner_tit_other animated fadeInLeft">公司动态</p>
            
            <p class="banner_tit_other_des animated fadeInRight">Our company</p>
        </div>
        <div class="ms-content-about" id="news-show-vue">
            <div class="ms-content-main">
                <#include "menu-left.htm">
                <div class="ms-content-right">
                    <div class="ms-content-right-position">
                        <a href="{ms:global.host/}">首页</a>
                        <span>></span>
                        <a href="{ms:field.typelink/}">{ms:field.typetitle/}</a>
                    </div>
                    <div class="ms-content-right-main">
                        <div class="ms-content-right-main-title" id="ms-content-right-main-title">
                            <div class="ms-content-right-main-title-div">{ms:field.title/}</div>
                            <div class="ms-content-right-main-icon">
                                <div class="ms-content-icon-left">
                                    <div class="ms-content-right-main-icon-source">来源：{ms:field.source/}
                                        <span class="ms-content-right-vertical">|</span>
                                    </div>
                                    <div class="ms-content-right-main-icon-time">时间：{ms:field.date?string("yyyy-MM-dd")/}</div>
                                </div>
                                <div class="ms-content-icon-right">
                                    <div class="ms-content-right-main-icon-clicks"></div>
                                    <div class="ms-content-right-main-icon-num">{ms:field.hit/}
                                        <span class="ms-content-right-vertical">|</span>
                                    </div>
                                    <div class="ms-content-right-main-icon-comment"></div>
                                    <div class="ms-content-right-main-icon-num">
                                        <span style="margin: 0;" v-text="commentsList.length"></span>
                                        <span class="ms-content-right-vertical">|</span>
                                    </div>
                                    <div class="ms-content-right-main-icon-Fabulous"></div>
                                    <div class="ms-content-right-main-icon-num" v-text="attentionNum"></div>
                                </div>
                            </div>
                        </div>
                        <div class="ms-content-right-main-content">
                            <p>{ms:field.content/}</p><br/>
                        </div>
                        <div class="metfield">
					        <p>上一篇：<a href="{ms:global.url/}{ms:pre.link/}">{ms:pre.title/}</a></p>
					        <p>下一篇：<a href="{ms:global.url/}{ms:next.link/}">{ms:next.title/}</a></p>
					    </div>
                    </div>
                    <div class="ms-content-right-main-content-Fabulous">
                        <div class="ms-content-right-main-content-icon" @click="attentionNews" :class="{'ms-is-attention':isAttention}"></div>
                    </div>
                    <div class="ms-content-right-comment">
                        <div class="ms-content-right-comment-input">
                            <textarea v-model='isButAttention' class="emotion" type="text" name="comments" placeholder="我有话说..."></textarea>
                            <div class="ms-content-right-comment-button">
                                <div class="ms-content-right-comment-expression" id="ms-face"></div>
                                <div class="ms-content-right-comment-submit" :class="{'ms-submit-comments-css':isButAttention.length>0}" @click="submitComments">提交</div>
                            </div>
                        </div>
                        <div class="ms-content-right-comment-list">
                            <div class="ms-content-right-comment-list-no-comment" style="display: none;" v-show="commentsList.length == 0">
                                <img src="{ms:global.host/}/{ms:global.style/}/images/no-comment.png">
                            </div>
                            <template v-for="(comments,index) in commentsList">
                                <div class="ms-content-right-comment-list-div" v-if="index <= listNum">
                                    <div class="ms-content-right-comment-list-left">
                                        <div class="ms-content-right-comment-list-portrait">
                                            <img :src="'{ms:global.host/}'+ comments.puIcon" onerror="this.src='http://cdn.mingsoft.net/global/images/msheader.png'">
                                        </div>
                                        <div class="ms-content-right-comment-list-content">
                                            <div class="ms-content-right-comment-list-name" v-text="comments.puNickname"></div>
                                            <div class="ms-content-right-comment-list-comment" v-html="vueAnalyticEmotion(comments.commentContent)"></div>
                                        </div>
                                    </div>
                                    <!--<div class="ms-content-right-comment-list-right">
                                        <div class="ms-content-right-main-icon-comment"></div>
                                        <div class="ms-content-right-main-icon-Fabulous"></div>
                                        <div class="ms-content-right-main-icon-num">28</div>
                                    </div>-->
                                </div>
                            </template>
                            <div class="ms-content-right-comment-list-div ms-content-right-active">
                                <div class="ms-content-right-comment-list-div-more" @click="listNum = listNum +4" v-show="listNum < commentsList.length">
                                    查看更多评论
                                </div>
                                <div class="ms-content-right-comment-list-div-no" v-show="listNum >= commentsList.length && commentsList.length != 0">
                                    没有更多评论
                                </div>
                                <div class="ms-content-right-comment-list-div-load" style="display: none;">
                                    <img src="{ms:global.host/}/{ms:global.style/}/images/loading.gif">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <#include "footer.htm">
    </body>
    <script>
        var newsShowVue = new Vue({
            el: "#news-show-vue",
            data: {
                commentsList: [], //评论列表
                attentionNum: 0, //点赞数
                isAttention: false, //点赞状态
                isButAttention: '', //按钮状态
                listNum: 4, //列表数
                loginStatus: '', //登录状态
                vueAnalyticEmotion: function(val) {
                    return AnalyticEmotion(val);
                },
            },
            methods: {
                //关注或者取消
                attentionNews: function() {
                    var obj = this;
                    if(this.loginStatus != true) {
                        alert("请先登录后重试");
                        return;
                    }
                    if(obj.isAttention == false) {
                        $.ajax({
                            type: "POST",
                            data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
                            url: "{ms:global.host/}/people/attention/save.do",
                            success: function(msg) {
                                if(msg.result) {
                                    obj.attentionNum++;
                                    obj.isAttention = true;
                                }
                            },
                            error: function() {
                                alert("操作失败，请检查是否已经安装关注插件");
                            }
                        })
                    } else {
                        $.ajax({
                            type: "POST",
                            data: "basicId={ms:field.id/}&basicAttentionType=2",
                            url: "{ms:global.host/}/people/attention/delete.do",
                            success: function(msg) {
                                if(msg.result) {
                                    obj.attentionNum--;
                                    obj.isAttention = false;
                                }
                            },
                            error: function() {
                                alert("操作失败，请检查是否已经安装关注插件");
                            }
                        })
                    }
                },
                //关注
                list: function() {
                    var obj = this;
                    $.ajax({
                        type: "POST",
                        data: "commentBasicId={ms:field.id/}",
                        url: "{ms:global.host/}/comment/list.do",
                        success: function(msg) {
                            obj.commentsList = msg.list;
                        }
                    })
                },
                //提交
                submitComments: function() {
                    if(this.isButAttention == '') {
                        return;
                    }
                    if(this.loginStatus != true) {
                        alert("请先登录后重试");
                        return;
                    }
                    var obj = this;
                    $.ajax({
                        type: "POST",
                        data: "commentContent=" + $("textarea[name=comments]").val() + "&isCode=false&commentBasicId={ms:field.id/}",
                        url: "{ms:global.host/}/people/comment/save.do",
                        success: function(msg) {
                            if(msg.result) {
                                alert("评论成功");
                                obj.list();
                            } else {
                                alert(msg.resultMsg);
                            }
                            obj.isButAttention = '';
                        },
                        error: function() {
                            alert("评论失败，请检查是否已经安装评论插件");
                        },
                    })
                }
            },
            mounted: function() {
                $('#ms-face').SinaEmotion($('.emotion'));
                var obj = this;
                //登录状态
                $.ajax({
                    type: "POST",
                    url: "{ms:global.host/}/checkLoginStatus.do",
                    success: function(msg) {
                        obj.loginStatus = msg.result;
                    }
                })

                //关注数
                $.ajax({
                    type: "POST",
                    data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
                    url: "{ms:global.host/}/attention/count.do",
                    success: function(msg) {
                        obj.attentionNum = msg;
                    }
                })
                //是否关注了
                $.ajax({
                    type: "POST",
                    data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
                    url: "{ms:global.host/}/people/attention/isExists.do",
                    success: function(msg) {
                        obj.isAttention = msg.result;
                    }
                })
            },
            beforeCreate: function() {
                var obj = this;
                var app_id = '1362404091';
                $.ajax({
                    async: true,
                    dataType: 'jsonp',
                    url: 'https://api.weibo.com/2/emotions.json?source=' + app_id,
                    success: function(response) {
                        var data = response.data;
                        for(var i in data) {
                            if(data[i].category == '') {
                                data[i].category = '默认';
                            }
                            if(emotions[data[i].category] == undefined) {
                                emotions[data[i].category] = new Array();
                                categorys.push(data[i].category);
                            }
                            emotions[data[i].category].push({
                                name: data[i].phrase,
                                icon: data[i].icon
                            });
                            uSinaEmotionsHt.put(data[i].phrase, data[i].icon);
                        }
                        obj.list();
                    }
                });
            },
        })
    </script>

</html>